package com.yeyks.rabbitmq.rabbitlistener;

import com.alibaba.fastjson.JSONObject;
import com.yeyks.newwebsocket.WebSocket;
import com.yeyks.rabbitmq.config.MqQueueConfig;
import com.yeyks.rabbitmq.queue.RabbitMqQueue;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @Author fuchangshuai
 * @date 2019/4/10 3:09 PM
 */
//@Component
//@Slf4j
public class OrderQueueListener {
//    @Autowired
//    private WebSocket webSocket;
//
//
//    @RabbitListener(bindings = @QueueBinding(value = @Queue(value = MqQueueConfig.ORDER_QUEUE_WEBSOCKET, durable = "true"),
//            exchange = @Exchange(value = MqQueueConfig.ORDER_WEBSOCKET_EXCHANGE, durable = "true", type = "topic"),
//            key = MqQueueConfig.ORDER_WEBSOCKET_KEY))
//    public void pushMessage(String message) {
//        try {
//            log.info("mq监听到的消息为{}", message);
//            JSONObject jsonObject = JSONObject.parseObject(message);
//            if (jsonObject != null) {
//                webSocket.sendMessageToMore((String) jsonObject.get("message"), (String) jsonObject.get("userId"));
//            }
//        } catch (Exception e) {
//            log.error("mq消息发送异常{}", message);
//        }
//    }


}
